<?= \common\widgets\Asset::widget(['type'=>['bootstrap-editable']])?>
<div class="layui-card-body" style="padding: 10px 0px">
    <div class="layui-collapse like-layui-collapse" lay-accordion=""
         style="border:1px dashed #c4c4c4">
        <div class="layui-colla-item">
            <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示<i
                    class="layui-icon layui-colla-icon"></i></h2>
            <div class="layui-colla-content layui-show" style="background-color: #fff">
                <p>*排序规则：<span style="color: red">排序值</span>越大越靠前。创建时间最新排最前面</p>
            </div>
        </div>
    </div>
</div>
<div class="col-sm-12 search-collapse">
    <form id="role-form">
        <div class="select-list">
            <ul>
                <li><?= \common\widgets\FormInput::widget(['name'=>'input|标题','extend'=>['name'=>'like[title]']])?></li>
                <li><?= \common\widgets\FormInput::widget(['name'=>'select|状态','extend'=>['name'=>'where[status]','value'=>'','place'=>'所有']])?></li>
                <li>
                    <?= $this->render('/iframe',['name'=>'searchbtn|搜索'])?>
                    <?= $this->render('/iframe',['name'=>'resetbtn|重置'])?>
                </li>
            </ul>
        </div>
    </form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
    <?= $this->render('/public/toolbar')?>
</div>
<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-table"></table>
</div>

<?php $this->beginBlock('script'); ?>
<script>
    $(function () {
        var options = {
            modalName: "卡券",
            sortName:'sort',
            sortOrder: "desc",
            showExport: false,
            columns: [
                {checkbox: true},
                {field: 'id', title: 'ID',  sortable: true},
                {
                    field: 'title',
                    title: '标题',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,20);
                    }
                },
                {field: 'campus', title: '限制校区'},
                {field: 'type', title: '类型'},
                {field: 'condition', title: '条件'},
                {field: 'discount_amount', title: '优惠金额'},
                {
                    field: "sort",
                    title: "排序",
                    editable:{type:'number'},
                    sortable: true,
                    formatter: function (value, row, index) {
                        return "<a class=\"data-sort\" href=\"#\" name=\"sort\" data-type=\"text\" data-pk=\""+row.id+"\" data-title=\"排序 数字越大越靠前\">" + value + "</a>";
                    }
                },
                {
                    title: '状态',
                    field: 'status',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.view.statusTools(row,true);
                    }
                },
                {field: 'create_time', title: '创建时间', align: 'center', sortable: true},
                {field: 'update_time', title: '更新时间', align: 'center', sortable: true,visible: false},
                {field: 'note', title: '备注',visible: false},
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return '<?=$this->render("/iframe",["name"=>"formopbtn","extend"=>["type"=>["edit","delete"],"rowId"=>"row.id"]])?>';
                    }
                }
            ],
            onLoadSuccess: function (aa, bb, cc) {
                $("#bootstrap-table .data-sort").editable({
                    url: function (params) {
                        setSort(this,params.value)
                    },
                    type: 'text'
                });
            }
        };
        $.table.init(options);
    });
</script>
<?php $this->endBlock(); ?>

